package com.bianguo.android.tencentpushdemo.view.activity;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.LinearSnapHelper;
import android.support.v7.widget.PagerSnapHelper;
import android.support.v7.widget.RecyclerView;

import com.bianguo.android.tencentpushdemo.R;
import com.bianguo.android.tencentpushdemo.adapters.PageAdapter;
import com.bianguo.android.tencentpushdemo.entity.PageData;

import java.util.ArrayList;

import butterknife.BindView;

public class RecyclerPageActivity extends BaseActivity {

    @BindView(R.id.page_recycler)
    RecyclerView pageRecycler;

    private ArrayList<PageData> pageDatas;
    private PageAdapter pagerAdapter;
    private LinearLayoutManager layoutManager;

    @Override
    public int layoutId() {
        return R.layout.activity_recycler_page;
    }

    @Override
    public void initView(Bundle savedInstanceState) {
        pageDatas = new ArrayList<>();
        int k = 0;
        for (int i = 1; i <= 5; i++) {
            PageData pageData = new PageData();
            ArrayList<String> datas = new ArrayList<>();
            int j = k;
            for (; j < k + 7; j++) {
                datas.add(i + j + "");
            }
            k = j - 1;
            pageData.setDatas(datas);
            pageDatas.add(pageData);
        }
        pagerAdapter = new PageAdapter(mContext, pageDatas);
        layoutManager = new LinearLayoutManager(mContext);
        layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
        pageRecycler.setLayoutManager(layoutManager);
//        LinearSnapHelper snapHelper = new LinearSnapHelper();
//        snapHelper.attachToRecyclerView(pageRecycler);
        PagerSnapHelper snapHelper = new PagerSnapHelper();
        snapHelper.attachToRecyclerView(pageRecycler);
        pageRecycler.setAdapter(pagerAdapter);
    }

    @Override
    public void initData() {

    }
}
